import 'package:flutter/material.dart';
import 'package:ichinesereader/controller/user.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/grids/leaderBoardDatagrid.dart';
import 'package:get/get.dart';

class LeaderBoardWorldTab extends StatefulWidget {
  @override
  State<LeaderBoardWorldTab> createState() => _LeaderBoardWorldTabState();
}

class _LeaderBoardWorldTabState extends State<LeaderBoardWorldTab> {
  final UserController _userController = Get.find();

  @override
  void initState() {
    Future.delayed(Duration(milliseconds: 100), (() {
      _userController.getLeaderBoardWord();
    }));
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Log.debug('build LeaderBoardWorldTab');

    return Container(
      child: Center(
          child: _userController.obx(
        (state) => LeaderBoardDataGrids(_userController.rankingsWord),
        onEmpty: Text('Leader board may be disabled'.tr),
      )),
    );
  }
}
